﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace UIListNews
{
    public partial class NewsDetail : V_ListTypeBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int newsid = ParentLoad.NewsID;
            var Data = IB.Common.Base.V_Base.Data;
            var news = (from n in Data.CV_News
                        where n.NewsID == newsid
                        select n).FirstOrDefault();
            if (news != null)
            {
                this.txtTitle.InnerHtml = news.Title;
                this.txtDescript.InnerHtml = news.ShortContent;
                this.txtContent.InnerHtml = news.Content;
                var newsnewer = (from n in Data.CV_News
                                 where n.NewsID > newsid
                                 orderby n.NewsID ascending
                                 select n).Take(10);

                var newolder = (from n in Data.CV_News
                                where n.NewsID < newsid
                                orderby n.NewsID descending
                                select n).Take(10);

                this.rptNewer.DataSource = newsnewer;
                rptNewer.DataBind();

                this.rptOlder.DataSource = newolder;
                rptOlder.DataBind();
            }
        }
    }
}